package main

import (
	"ginVueNew/common"
	"github.com/gin-gonic/gin"
	_ "github.com/go-sql-driver/mysql"
	"github.com/spf13/viper"
	"os"
)


func main(){
	InitConfig()
	db := common.InitDB()
	defer db.Close()
	r := gin.Default()
	r = CollectRoute(r)
	port := viper.GetString("servser.port") //启动端口
	if port != ""{
		panic(r.Run(":" + port))
	}
}


func InitConfig(){
	workDir,_ := os.Getwd() //获取工作路径
	viper.SetConfigName("application") //配置文件名
	viper.SetConfigType("yml") //配置文件类型
	viper.AddConfigPath(workDir + "/config") //文件路径
	err := viper.ReadInConfig()
	if err != nil{
		panic(err)
	}
}



